<?php
namespace app\api\controller;

use app\common\lib\Arr;
use app\common\lib\Show;
use think\facade\Cache;

class Cart extends AuthBase {
    public function add(){
        if (!$this->request->isPost()){
//            return Show::error();
        }
        $id = input('param.id',0,'intval');
        $num = input('param.num',0,'intval');
        if (empty($id) || empty($num)){
            return Show::error([], '参数不合法');
        }
        $res = (new \app\common\business\Cart())->insertRedis($this->userId, $id, $num);
        if ($res === FALSE){
            return Show::error();
        }
        return Show::success();
    }
}